package com.nali.dal.expression;

import java.io.Serializable;

public class PropertyExpression<T extends Expression> implements Serializable {
	private static final long serialVersionUID = -2615526219166141326L;
	private String propertyName;
	private T expression;
	@SuppressWarnings("unused")
	private PropertyExpression() {
	}
	public PropertyExpression(String propertyName, T expression) {
		super();
		this.propertyName = propertyName;
		this.expression = expression;
	}
	public String getPropertyName() {
		return propertyName;
	}
	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}
	public T getExpression() {
		return expression;
	}
	public void setExpression(T expression) {
		this.expression = expression;
	}
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof PropertyExpression) {
			PropertyExpression<?> targ = (PropertyExpression<?>) obj;
			if(propertyName.equals(targ.propertyName) && expression.equals(targ.expression)) {
				return true;
			}
		}
		return false;
	}
	@Override
	public int hashCode() {
		int hashCode = 17; 
		hashCode = hashCode * 31 + propertyName.hashCode();
		hashCode = hashCode * 31 + expression.hashCode();
		return hashCode;
	}
	@Override
	public String toString() {
		return expression + "(" + propertyName + ")";
	}
}
